import ReactDOM from 'react-dom/client'

import Loading from './loading'

// 显示loading
export const showLoading = () => {
  const dom = document.createElement('div')
  dom.className = 'lt-loading'
  document.body.appendChild(dom)
  ReactDOM.createRoot(dom).render(<Loading />)
}

// 关闭loading
export const hideLoading = () => {
  const dom = document.querySelector('.lt-loading')
  if (dom) {
    document.body.removeChild(dom)
  }
}
